<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="110px">
        <el-form-item label="用户名" prop="realName">
          <el-input v-model="queryParams.realName" placeholder="请输入用户名" clearable size="small"
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="用户电话" prop="phonenumber">
          <el-input v-model="queryParams.phonenumber" placeholder="请输入用户电话" clearable size="small"
            @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="申请日期" prop="createTime">
          <el-date-picker @change="createTimeChange" v-model="createTime" type="daterange" range-separator="至"
                  start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd">
                </el-date-picker>
        </el-form-item>
        <!-- <el-form-item label="申请金额" prop="">
          <el-input v-model="queryParams.mobile" placeholder="请输入申请金额" clearable size="small"
            @keyup.enter.native="handleQuery" ><div slot="append">元</div></el-input>
        </el-form-item> -->
        <el-form-item label="打款状态" prop="status">
          <el-select clearable v-model="queryParams.status" placeholder="请选择打款状态">
            <el-option key="0" label="未打款" value="0"></el-option>
            <el-option key="1" label="已打款" value="1"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['system:user:export']"
          >导出</el-button>
        </el-form-item>
      </el-form>
      <!-- <el-row :gutter="10" class="mb8">
        <el-col :span="2">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['system:user:export']"
          >导出</el-button>
        </el-col>
      </el-row> -->


      <el-table v-loading="loading" :data="tabList" @selection-change="handleSelectionChange">
        <el-table-column label="技师名字" align="center" prop="realName" />
        <el-table-column label="技师电话" align="center" prop="phonenumber" />
        <el-table-column label="申请日期" align="center" prop="tradeTime" />
        <el-table-column label="提现金额" align="center" prop="changeBalance" />
        <el-table-column label="提现手续费" align="center" prop="shouxuFei" />
        <el-table-column label="打款金额" align="center" prop="actualAmount" />
        <el-table-column label="提现银行" align="center" prop="bankName" />
        <el-table-column label="提现卡号" align="center" prop="bankCard" />
        <el-table-column label="操作" align="center" prop="">
          <template slot-scope="scope">
            <div v-if="scope.row.status == '0'" @click="statusClick(scope.row)" style="color:cornflowerblue;cursor: pointer;">打款</div>
            <div v-else>已打款</div>
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
    </div>
  </template>
    
  <script>
  import { jstixianlist,dakuan} from "@/api/collectionBill/collectionBill";
  export default {
    name: "Knowledge",
    components: {
    },
    data() {
      return {
        // 遮罩层
        loading: false,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 表格数据
        tabList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        companyTypeOptions: [],
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          realName:null,
          phonenumber:null,
        },
        createTime:'',
        czbeginTime: '',
        czendTime: '',
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.queryParams.czbeginTime = this.czbeginTime;
        this.queryParams.czendTime = this.czendTime;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.createTime = ''
        this.czbeginTime = ''
        this.czendTime = ''
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length !== 1
        this.multiple = !selection.length
      },
      /** 查询列表 */
      getList() {
        this.loading = true;
        jstixianlist(this.queryParams).then(response => {
          this.tabList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      createTimeChange() {
        this.czbeginTime = this.createTime[0] 
        this.czendTime = this.createTime[1]
      },
      //打款
      statusClick(row){
        this.$confirm('确认打款', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return dakuan({
            id: row.id,
            status: 1
          });
        }).then(() => {
          this.$message({message: '打款成功',type:'success'});
          this.getList();
        })
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('walletchange/walletchange/jstixian/export', {
          ...this.queryParams
        }, `jishitixian_${new Date().getTime()}.xlsx`)
      },
    }
  };
  </script>
  <style>
  </style>
    